package com.hl.ui;

import java.util.ArrayList;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;

import com.hl.R;
import com.hl.adapter.OrderAllAdapter;
import com.hl.app.XiaoMiApplication;
import com.hl.bean.OrderBean;
import com.hl.util.LogUtils;
import com.hl.util.OrderUtils;

public class NotuseOrder {
	protected static final String TAG = NotuseOrder.class.getSimpleName();
	private MyOrderActivity activity;
	private View view;
	private ListView lv;
	private OrderAllAdapter adapter;
	private ArrayList<OrderBean> list;

	public NotuseOrder(final MyOrderActivity activity) {
		super();
		this.activity = activity;

		view = activity.getLayoutInflater().inflate(
				R.layout.item_order_list, null);
		
		initView();
		
		lv.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> arg0, View arg1,
					int position, long id) {
				// TODO Auto-generated method stub
				LogUtils.i(TAG, ""+position);
				OrderBean order = adapter.getItem(position);
				Intent intent =new Intent();
				intent.setClass(activity, DetailsActivity.class);
				intent.putExtra("order", order.getOrderNo());
				intent.putExtra("state", order.getStatus());
				activity.startActivity(intent);
				activity.finish();
			}
		});
	}

	private void initView() {
		// TODO Auto-generated method stub
		lv = (ListView) view
				.findViewById(R.id.activity_center_myorder_listview_notuserorder);
		list=OrderUtils.checkOrderStatetrue(XiaoMiApplication.getInstance().alllist);
		adapter = new OrderAllAdapter(list, activity,"not");
		lv.setAdapter(adapter);
		
	}

	public View getView() {
		// TODO Auto-generated method stub
		return view;
	}
}
